package com.zmn.plat.common.dictionary;

/**
 * 渠道类型
 *
 * @author xiangjunming
 * @since 2019 /08/20 14:47:16
 */
public enum ChannelCommissionBaseTypeEnum {

    /**
     * values
     */
    CHANNEL(1, "渠道收款"),
    ORDER(2, "订单收入"),
    ACHIEVEMENTS(3, "绩效基数金额"),
    EXTERNAL(4, "外部价"),;

    /**
     * 渠道收款
     */
    public static final int CONSTS_CHANNEL = 1;
    /**
     * 订单收入
     */
    public static final int CONSTS_ORDER = 2;
    /**
     * 绩效基数金额
     */
    public static final int CONSTS_ACHIEVEMENTS = 3;
    /**
     * 外部价
     */
    public static final int CONSTS_EXTERNAL = 4;

    private Integer code;
    private String name;

    ChannelCommissionBaseTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ChannelCommissionBaseTypeEnum of(Integer code) {
        if(code == null || code == 0){
            return null;
        }
        switch (code) {
            case 1:
                return CHANNEL;
            case 2:
                return ORDER;
            case 3:
                return ACHIEVEMENTS;
            case 4:
                return EXTERNAL;
            default:
                return null;
        }
    }

    public static String getName(Integer code) {
        ChannelCommissionBaseTypeEnum of = of(code);
        return of == null ? null : of.getName();
    }
}
